#!/usr/bin/env ruby
#
# Uploads a single state which is the only argument
#

def main(argv)

  def e(s)
    STDERR.puts s
  end

  if argv.empty?
    e 'Usage ' + File.basename(__FILE__) + ' <state>'
    exit 0
  end

  state = argv.shift
  if !File.exists? state
    e state + ' doesn\'t exist'
    exit 1
  end

  if !File.directory? state
    e state + ' should be a directory'
    exit 1
  end

  system 'ant -Dstate=' + state + ' upload.state.xml'
end

main ARGV
